Conversation
- Add _locales/fr/messages.json - Add Français to UI selector - Detect fr in browser language - Support fr in shared error messages
…anguages - Introduced new error messages for translation API errors, request errors, and generic translation failures in English, Spanish, French, Japanese, Korean, Simplified Chinese, and Traditional Chinese. - Updated localization files to enhance user feedback during translation issues.
Reviewer's GuideThis PR refactors translation error handling by removing hardcoded messages and leveraging Chrome’s i18n API with centralized locale entries (now including French), and extends UI language support by adding French in detection logic and the settings dropdown. Entity relationship diagram for locale message files with new French supporterDiagram
EN_MESSAGES {
errTranslationApi VARCHAR
errTranslationRequest VARCHAR
errTranslationGeneric VARCHAR
}
ES_MESSAGES {
errTranslationApi VARCHAR
errTranslationRequest VARCHAR
errTranslationGeneric VARCHAR
}
JA_MESSAGES {
errTranslationApi VARCHAR
errTranslationRequest VARCHAR
errTranslationGeneric VARCHAR
}
KO_MESSAGES {
errTranslationApi VARCHAR
errTranslationRequest VARCHAR
errTranslationGeneric VARCHAR
}
ZH_CN_MESSAGES {
errTranslationApi VARCHAR
errTranslationRequest VARCHAR
errTranslationGeneric VARCHAR
}
ZH_TW_MESSAGES {
errTranslationApi VARCHAR
errTranslationRequest VARCHAR
errTranslationGeneric VARCHAR
}
FR_MESSAGES {
errTranslationApi VARCHAR
errTranslationRequest VARCHAR
errTranslationGeneric VARCHAR
}
EN_MESSAGES ||--|| ES_MESSAGES : same keys
EN_MESSAGES ||--|| JA_MESSAGES : same keys
EN_MESSAGES ||--|| KO_MESSAGES : same keys
EN_MESSAGES ||--|| ZH_CN_MESSAGES : same keys
EN_MESSAGES ||--|| ZH_TW_MESSAGES : same keys
EN_MESSAGES ||--|| FR_MESSAGES : same keys
Class diagram for updated error message handling in subtitleUtilities.jsclassDiagram
class subtitleUtilities {
+getUILanguage()
+getLocalizedErrorMessage(errorTypeKey, details)
}
subtitleUtilities : -getUILanguage() updated to support 'fr'
subtitleUtilities : -getLocalizedErrorMessage() refactored to use chrome.i18n.getMessage()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Pull Request Overview
This PR enhances internationalization support by adding French as a supported UI language and centralizing error message handling through locale files. The changes remove hardcoded error messages and improve consistency across all supported languages.
- Added French language support throughout the application
- Centralized translation error messages into locale files for all supported languages
- Refactored error message retrieval to use Chrome's i18n API instead of hardcoded messages
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| translation_providers/geminiVertexTranslate.js | Added test comment (no functional impact) |
| options/components/sections/GeneralSection.jsx | Added French language option to UI language dropdown |
| content_scripts/shared/subtitleUtilities.js | Removed hardcoded error messages and updated getLocalizedErrorMessage to use Chrome i18n API |
| config/configSchema.js | Added French language detection support |
| _locales/*/messages.json | Added centralized error message translations for all supported languages |
| _locales/fr/messages.json | Complete French translation file for the entire application |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Remove the leftover testing comment in translation_providers/geminiVertexTranslate.js to avoid clutter.
- Instead of returning an empty string when getLocalizedErrorMessage fails, include a sensible fallback (e.g., default English message) so users still see an error.
- Verify that the new fr/messages.json contains translations for errTranslationApi, errTranslationRequest, and errTranslationGeneric to prevent missing locale entries.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Remove the leftover testing comment in translation_providers/geminiVertexTranslate.js to avoid clutter.
- Instead of returning an empty string when getLocalizedErrorMessage fails, include a sensible fallback (e.g., default English message) so users still see an error.
- Verify that the new fr/messages.json contains translations for errTranslationApi, errTranslationRequest, and errTranslationGeneric to prevent missing locale entries.
## Individual Comments
### Comment 1
<location> `content_scripts/shared/subtitleUtilities.js:303-312` </location>
<code_context>
-const localizedErrorMessages = {
</code_context>
<issue_to_address>
**issue (bug_risk):** Removing hardcoded localized error messages may impact fallback behavior if i18n is unavailable.
Since the function now returns an empty string if chrome.i18n fails, users may not see any error message. Please add a basic fallback to ensure error feedback is always displayed.
</issue_to_address>
### Comment 2
<location> `content_scripts/shared/subtitleUtilities.js:338` </location>
<code_context>
- fallbackMessages['en'] ||
- '[Translation Error]'
- );
+ return '';
}
</code_context>
<issue_to_address>
**issue (bug_risk):** Returning an empty string as a fallback may lead to silent failures in the UI.
If chrome.i18n is unavailable, return a generic error message instead of an empty string to ensure users receive feedback.
</issue_to_address>
### Comment 3
<location> `translation_providers/geminiVertexTranslate.js:23` </location>
<code_context>
'vertexModel',
]);
// test gpg sign
+ //test the sign again what is going on
const model = config.vertexModel || 'gemini-2.5-flash';
</code_context>
<issue_to_address>
**nitpick:** Comment added appears to be a debugging note; consider removing or clarifying.
The comment lacks context and could confuse future maintainers. Please remove it if unnecessary, or clarify its relevance.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…errorTypeKey instead of an empty string, improving error handling. - Removed outdated comments in geminiVertexTranslate.js for better code clarity.
This pull request focuses on improving internationalization and error handling for translation features. The main changes are the centralization of error messages into locale files, the addition of French language support, and refactoring how localized error messages are retrieved.
Internationalization improvements:
errTranslationApi,errTranslationRequest,errTranslationGeneric) into all locale files (_locales/en/messages.json,_locales/es/messages.json,_locales/ja/messages.json,_locales/ko/messages.json,_locales/zh_CN/messages.json,_locales/zh_TW/messages.json) for consistent and maintainable error messaging across supported languages. [1] [2] [3] [4] [5] [6]fr) as a supported UI language in language detection logic (config/configSchema.js,content_scripts/shared/subtitleUtilities.js) and in the language selection dropdown (options/components/sections/GeneralSection.jsx). [1] [2] [3]Error message handling refactor:
localizedErrorMessagesfromsubtitleUtilities.jsand updatedgetLocalizedErrorMessageto use Chrome's i18n API for fetching error messages, ensuring messages are always up-to-date with locale files. [1] [2]Other:
translation_providers/geminiVertexTranslate.js(no functional impact).Summary by Sourcery
Centralize translation error messages into locale files, introduce French UI language support, and refactor error message retrieval to use Chrome’s i18n API.
New Features:
Enhancements:
Documentation:
Chores: